package com.meixiang.fragment.shopping;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.meixiang.R;
import com.meixiang.fragment.service.BaseViewPagerFragment;

/**
 * 商品详情图文信息页
 *
 * @author LZRUI
 */
public class GoodsImageTextViewPagerFragment extends BaseViewPagerFragment implements GoodsEvaluateFragment.EvaluateTitleListener {

    private static String GOODS_ID = "goods_id";
    private String goodsId;

    public GoodsImageTextViewPagerFragment() {
    }

    public GoodsImageTextViewPagerFragment newInstance(String goodsId) {
        GoodsImageTextViewPagerFragment fragment = new GoodsImageTextViewPagerFragment();
        Bundle bundle = new Bundle();
        bundle.putString(GOODS_ID, goodsId);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            goodsId = getArguments().getString(GOODS_ID);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        setBackground(R.color.goods_view_pager_title_bg);
        isCuttingLine(false);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

    @Override
    protected String[] getTitles() {
        return new String[]{"图文信息", "商品参数", "评价"};
    }

    @Override
    protected Fragment[] getFragments() {
        GoodsEvaluateFragment evaluateFragment = GoodsEvaluateFragment.newInstance(goodsId);
        evaluateFragment.setEvaluateTitleListener(this);
        return new Fragment[]{ GoodsImageTextFragment.newInstance(goodsId),GoodsParamsFragment.newInstance(goodsId), evaluateFragment};
    }

    @Override
    protected int ColorStyle() {
        return R.color.goods_red_btn;
    }

    @Override
    public void setText(String title) {
        setTabText(2, "评价(" + title + ")");
    }
}
